Ext.define('Skood.controller.MainController',{
	extend:'Ext.app.Controller',
	/*stores:['SecurityMenuStore',
	        'UserJsonStore',
	        'RoleStore'],移动到app.js中*///为什么这里不加store，grid显示不出来报错呢？
	//models:['RoleModel'],
	init:function(){
		var me = this;
		me.control({
			/*
			'securityTreePanel':{
				itemdblclick:{
					fn:me.onSecurityTreeItemClick,
					scope:me
				}
			}//'securityTreePanel与'#menuTree'获取的对象一样
			*/
			'#menuTree':{
				itemdblclick:{
					fn:me.onSecurityTreeItemClick,
					scope:me
				}
			}
		});
	},
	
	onSecurityTreeItemClick: function(view, record, item, index, e, options) {
        if (record.isLeaf()) {
            var mainPanel = Ext.getCmp('mainPanel');
            var tab = Ext.getCmp(record.raw.code);
            if(!tab){
            	mainPanel.add({xtype: 'panel',
                            //title: record.raw.text,
                            title: record.raw.name,
                            id:record.raw.code,
                            height: 100,
                        	closable:true,
                        	iconCls: 'user',
                            items: [
                                {
                                    xtype: record.raw.view                                    
                                }
                            ]/*,
                            dockedItems: [
                                {
                                    xtype: 'pagingtoolbar',
                                    dock: 'bottom',
                                    store:'UserJsonStore',
                                    width: 360,
                                    displayInfo: true
                                }
                            ]*/}).show();
            }else{
            	mainPanel.setActiveTab(tab);
            }
        }
    },
    addTab:function(){
    	
    }
    
});